/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package verins.DAO;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.swing.JOptionPane;





/**
 *
 * @author yi
 */
public class TUbigeoDAO {
    
    
    /*
         public boolean save(Tipopartidopolitico tipoPartido){
      try{
        // Create the EntityManager
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("verinsPU");
        EntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        em.persist(tipoPartido);
        em.getTransaction().commit();
        em.close();
        emf.close();
        return true;
      }catch(Exception ex){
          JOptionPane.showMessageDialog(null, "Error al grabar datos"+ex.getMessage());
          return false;
      }
    }

 */


       public List finDptoAll(){
        List lista=null;
        String codDpto=new String();
        String subStr=new String();
        
        try{

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("verinsPU");
            EntityManager em = emf.createEntityManager();
            Query query=em.createNamedQuery("Tubigeo.findAll");

            lista=query.getResultList();
            
            
            if(em.getTransaction().isActive())
                em.getTransaction().commit();
            em.close();
            emf.close();

            return lista;

        }catch(Exception ex){
            System.out.println(ex.getMessage());
        }
        return lista;
    }


    
}
